using System;

namespace Visualization
{
	/// <summary>
	/// Summary description for Math.
	/// </summary>
	public class Math2
	{
		private Math2()
		{
		}
		public static double ToRadians(double degrees)
		{
			return (double)(System.Math.PI/180 * degrees);
		}
		public static double ToDegrees(double radians)
		{
			return (double)(180/System.Math.PI * radians);
		}
		public static bool Between(double value, double left, double right)
		{
			return value>=left && value<=right;
		}
		public static bool NearlyEqual(ref double val1, ref double val2, ref double tolerance)
		{
			if(val1 != 0)
			{
				double diff = Math.Abs((val1 - val2)/val1);
				return diff <= tolerance;
			}
			else
			{
				return Math.Abs(val2) <= tolerance;
			}
		}
		public static bool NearlyEqual(double val1, double val2, double tolerance)
		{
			val1 = Math.Abs((val1 - val2)/val1);
			return val1 <= tolerance;
		}
	}
}
